<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\agent\controller;

class UserController extends \app\AgentRest
{
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
    }
    public function updateSelfPasswd()
    {
        if(defined("IS_WEIQIN")) {
            return $this->error(lang("没有权限"));
        }
        $input = $this->_input;
        if(isset($input["admin"])) {
            $input = $input["admin"];
        }
        $user = $this->_user;
        if(isset($user["admin_id"]) && !empty($user["admin_id"])) {
            $admin_model = new \app\agent\model\AdminModel();
            $user = $admin_model->getAdmin(["admin_id" => $user["admin_id"]]);
            if(empty($user)) {
                return $this->error(lang("admin is not exist"));
            }
            $check = checkPasswd($input["old_passwd"], $user["offset"], $user["passwd"]);
            if(!$check) {
                return $this->error(lang("old passwd error"));
            }
            $passwd = createPasswd($input["new_passwd"], $user["offset"]);
            $admin_model = new \app\agent\model\AdminModel();
            $result = $admin_model->updateAdmin(["admin_id" => $user["admin_id"]], ["passwd" => $passwd]);
            return $this->success($result);
        }
        return $this->error(lang("admin is not exist"));
    }
}

?>